//尺寸比例计算（页面宽度已750为准，即750*scale，所有尺寸乘以scale，即可兼容各种大小屏幕）
const scale = uni.getSystemInfoSync().windowWidth / 750;

/**
 * @Description: 单行文字
 * @Author: ZhangHan
 * @Date: 2025-08-25 18:00:38
 */
export const drawNormalText = (
  ctx: any,
  str: string,
  x: number,
  y: number,
  font: number,
  style: string,
  align: CanvasTextAlign,
  baseLine: CanvasTextBaseline
) => {
  ctx.setFontSize(font * scale);
  ctx.setFillStyle(style);
  ctx.setTextAlign(align);
  ctx.setTextBaseline(baseLine);
  ctx.fillText(str, x * scale, y * scale);
};

//获取canvas画布的实际尺寸
export const getCanvasSize = (classname: any, nodeInfo: any): Promise<any> => {
  return new Promise((resolve, reject) => {
    const query = uni.createSelectorQuery().in(nodeInfo);
    query
      .select(classname)
      .fields({ size: true }, (res: any) => {
        if (res) {
          resolve(res);
        } else {
          reject("获取画布尺寸失败");
        }
      })
      .exec();
  });
};
